<div class="rightbanner"><img src="<?php echo Mage::getModel('catalog/category')->load(51)->getImageUrl();?>" alt="Freshly Forked" width="792"/></div>
<div class="productlist">
	<?php
	$products = $this->getLoadedProductCollection();
	$ic = 0;
	foreach ($products as $product) {
		$pid = $product->getId();
		$_product = Mage::getModel('catalog/product')->load($pid);
		if ($ic>=8) {
			break;
		}
		//print_r($_product->getUrlPath());
		//print_r($_product->getCategoryIds());
		$p_url = "";
		if ($_product->getCategoryIds()) {
			$cid_arr = $_product->getCategoryIds();
			$cid = Mage::getModel('catalog/category')->load($cid_arr[0]);
			$cate_arr = $cid->getParentCategories();
			foreach ($cate_arr as $cate) {
				$p_url .= $cate->getUrlKey()."/";
				//print_r($cate->getUrlKey());
			}
			
		}
		$_price = $this->helper('tax')->getPrice($_product, $_product->getPrice());
	    $_finalPrice = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice());
		$discount=0;
	    if($_finalPrice<$_price){
	    	$discount=round(($_price-$_finalPrice)/$_price/5,2);
	    	$discount=round($discount*5*100);
	    	//echo '$discount='.$discount;
	    }
	?>
	<div class="productitem">

		<div class="productimg">
		<?php
		if($discount) {
		?>
		<img src="<?php echo $this->getSkinUrl()?>images/<?php echo $discount?>_pct.png" alt="<?php echo $discount?>% off" class="offimg" />
		<?php 
		}
		?>
		<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(146, 146); ?>" alt="<?php echo $this->htmlEscape($_product->getName()) ?>" /></div>
        <p class="title"><a href="<?php echo $this->getUrl().$p_url; ?><?php echo $_product->getUrlKey().".html"; ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
        <div> <span class="price"><?php echo Mage::helper('core')->currency($this->helper('tax')->getPrice($_product, $_product->getFinalPrice()),true,false) ?></span> <a href="<?php echo $this->getAddToCartUrl($_product);?>" class="buybtn"></a> </div>

	</div>
	<?php
		if($ic%4==3){
			echo '<div class="clearboth"></div>';
		}
		$ic ++;
	}
	?>
</div>